<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<%@ include file="../../common/jsp/sheetHeader.jsp" %>
<script src="../../common/CryptoJS/rollups/aes.js"></script>
<script>
	$(document).ready(function() {
		//sheet 초기화  
		createIBSheet2(document.getElementById("viewArea"),"mySheet","100%","300px");
		
		var cfg = {FrozenCol:3,SearchMode:smLazyLoad,Page:30,MergeSheet:msPrevColumnMerge};
		var headers = [
			{Text:"NO|상태|삭제|체크박스|더미체크|라디오|텍스트|멀티라인|콤보|Edit콤보|팝업|Edit팝업|정수|실수|계산1\n(실수/3)|계산2\n(계산1*2)|정수(Null)|실수(Null)|년월일|년월|월일|시분초|시분|주민등록번호|사업자번호|카드번호|우편번호|주민번호마스킹|이미지|암호",Align:"Center"}
		];
		var info = {Sort:1,ColMove:1,ColResize:1,HeaderCheck:0};
		var cols = [
			{Type:"Seq",Width:50,SaveName:"sSeq",Align:"Center"},
			{Type:"Status",Width:50,SaveName:"sStatus",Align:"Center"},
			{Type:"DelCheck",Width:50,SaveName:"sDelete",Align:"Center",Hidden:1},
			{Type:"CheckBox",Width:80,SaveName:"sCheck",Align:"Center",Hidden:1},
			{Type:"DummyCheck",Width:70,SaveName:"sDummy",Align:"Center",HeaderCheck:0},
			{Type:"Radio",Width:60,SaveName:"sRadio",Align:"Center"},
			{Type:"Text",Width:70,SaveName:"sText",Align:"Center",KeyField:1,ColMerge:1,Wrap:1, BackColor:'#FF9E9B'},
			{Type:"Text",Width:70,SaveName:"sMultiLine",Align:"Center", MultiLineText:1},
			{Type:"Combo",Width:85,SaveName:"sCombo",Align:"Center",ColMerge:0,ComboText:"전체|평일|주말|여름성수기|겨울성수기",ComboCode:"*|1|2|3|4"},
			{Type:"ComboEdit",Width:80,SaveName:"sComboEdit",Align:"Left",ColMerge:0,ComboText:"전체|한화콘도|한국콘도|글로리콘도|삼립하일라|두산콘도",ComboCode:"100|101|105|110|115|120"},
			{Type:"Popup",Width:130,SaveName:"sPopup",Align:"Left",ColMerge:0},
			{Type:"PopupEdit",Width:65,SaveName:"sPopupEdit",Align:"Right"},
			{Type:"AutoSum",Width:80,SaveName:"sInteger",Align:"Right",ColMerge:0,Format:"Integer"},
			{Type:"AutoSum",Width:80,SaveName:"sFloat",Align:"Right",ColMerge:0,Format:"Float",PointCount:2},
			{Type:"AutoSum",Width:80,SaveName:"sFloatCalc",Align:"Right",ColMerge:0,Format:"Float",CalcLogic:"|13|/3",PointCount:2},
			{Type:"AutoSum",Width:80,SaveName:"sNullFloatCalc",Align:"Right",ColMerge:0,Format:"NullFloat",CalcLogic:"|14|*2",PointCount:2},
			{Type:"AutoSum",Width:80,SaveName:"sNullInteger",Align:"Right",ColMerge:0,Format:"NullInteger"},
			{Type:"AutoSum",Width:80,SaveName:"sNullFloat",Align:"Right",ColMerge:0,Format:"NullFloat",PointCount:2},
			{Type:"Date",Width:90,SaveName:"sDateYmd",Align:"Center",ColMerge:0,Format:"Ymd"},
			{Type:"Date",Width:80,SaveName:"sDateYm",Align:"Center",ColMerge:0,Format:"Ym"},
			{Type:"Date",Width:70,SaveName:"sDateMd",Align:"Center",ColMerge:0,Format:"Md"},
			{Type:"Date",Width:60,SaveName:"sDateHms",Align:"Center",ColMerge:0,Format:"Hms"},
			{Type:"Date",Width:60,SaveName:"sDateHm",Align:"Center",ColMerge:0,Format:"Hm"},
			{Type:"Text",Width:120,SaveName:"sTextId",Align:"Center",ColMerge:0,Format:"IdNo"},
			{Type:"Text",Width:110,SaveName:"sTextSaup",Align:"Center",ColMerge:0,Format:"SaupNo"},
			{Type:"Text",Width:140,SaveName:"sTextCard",Align:"Center",ColMerge:0,Format:"CardNo"},
			{Type:"Text",Width:90,SaveName:"sTextPost",Align:"Center",ColMerge:0,Format:"PostNo"},
			{Type:"Text",Width:120,SaveName:"sUserFormat",Align:"Center",ColMerge:0,Format: "######-*******"},
			{Type:"Image",Width:70,SaveName:"sImage",Align:"Center",ColMerge:0},
			{Type:"Pass",Width:70,SaveName:"sPass",Align:"Center",ColMerge:0}
		];
	
		mySheet.SetConfig(cfg);
		mySheet.InitHeaders(headers,info);
		mySheet.InitColumns(cols);
	
		doAction("search");
	});
	
	/*Sheet 각종 처리*/
	function doAction(sAction) {
		switch(sAction) {
			case "search":		//조회
				mySheet.DoSearch("../data/Down2Excel_data.xml");
				break;
		}
	}
	
	function mySheet_OnMouseUp(Button, Shift, X, Y) {
		if (Button == 0) {
			var val = mySheet.RowSaveStr(mySheet.MouseRow());
			$('#msg').val(val);
		}
	}
	
	function testEncDec() {
		var msg = $('#msg').val();
		
	    var encrypted = CryptoJS.AES.encrypt(msg, "Secret Passphrase");
	    $('#encMsg').val(encrypted.toString());
	    
		var decrypted = CryptoJS.AES.decrypt(encrypted, "Secret Passphrase");
		$('#decMsg').val(decrypted.toString(CryptoJS.enc.Utf8));
	}
</script>
<title>crypto 암/복호화 모듈 사용 예제</title>
</head>
<body>
<div id="main">
	<%@ include file="../../common/jsp/sheetNavi.jsp" %>	
	<div id="title">crypto 암/복호화 모듈 사용 예제</div>
	<div id="desc">
		Crypto.js 의 aes.js를 통해 AES 암호화 방식을 적용한다.
		<!--
			https://code.google.com/p/crypto-js/#AES
		-->
	</div>

	<div id="functionArea">
		<span>
			메시지 : <input type="text" size="100" id="msg" value=""/>
			<input type="button" value="암호화 복호화" onclick="testEncDec()">
		</span>
		<div>
			암호화 : <input type="text" size="100" id="encMsg" readonly/>
		</div>
		<div>
			복호화 : <input type="text" size="100" id="decMsg" readonly/>
		</div>
	</div>
	
	<div id="viewArea">
	</div>
</div>
</body>
</html>